<!DOCTYPE html>
<html>
    <head>
        <script src="js/vue.js"></script>
        <style>
            .row-enter{
                width: 100px;
            }

            .row-enter-to {
                width: 200px;
            }

            .row-enter-active {
                transition: width 3s;
            }

            .red {
                background: red;
                height: 20px;
            }

            .blue {
                background: blue;
                height: 20px;
            }

            .yellow {
                background: yellow;
                height: 20px;
            }

        </style>
    </head>
    <body>
        <div id="app">
            <button @click="showNum">切换</button>
            <transition name="row">
                <div class="red" v-bind:key="show">{{showText}}</div>
            </transition>
        </div>
        <script>
            var vm = new Vue({
                el:'#app',
                data : {
                    show : 'A'
                },
                methods : {
                    showNum() {
                        if(this.show == 'A'){
                            this.show = 'B';
                        }
                        else if (this.show == 'B') {
                            this.show = 'C';
                        }
                        else {
                            this.show = 'A';
                        }
                    }
                },
                computed : {
                    showText() {
                        switch (this.show) {
                            case 'A': return '我是a'
                            case 'B': return '我是b'
                            case 'C': return '我是c'
                        }
                    }
                }
            });
        </script>
    </body>
</html>